# -*- coding: utf-8 -*-

###########################################################################
#
#   Copyright (c) 2020  Bresee, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################

# http return info 


from flask import make_response, jsonify


def _response_success_data(data):
    return {"success": True, "code": 200, "msg": "success", "data": data}


def _response_success_no_data():
    return {"success": True, "code": 200, "msg": "success"}


def _response_error_data(msg, code):
    return {"success": False, "msg": msg, "code": code}


def _response_success_no_data_tech():
    return {"success": True, "code": "200", "msg": "success"}


def _response_success_data_tech(data):
    return {"success": True, "code": "200", "msg": "success", "data": data}


def make_response_success_no_data():
    return make_response(jsonify(_response_success_no_data()), 200)


def make_response_success(data):
    return make_response(jsonify(_response_success_data(data)), 200)


def make_response_success_no_data_tech():
    return make_response(jsonify(_response_success_no_data_tech()), 200)


def make_response_success_tech(data):
    return make_response(jsonify(_response_success_data_tech(data)), 200)


 


def make_response_400():
    return make_response(jsonify(_response_error_data("请求无效", 400)), 400)


def make_response_401():
    return make_response(jsonify(_response_error_data("权限不足", 200)), 200)


def make_response_403():
    return make_response(jsonify(_response_error_data("禁止访问", 403)), 403)


def make_response_404():
    return make_response(jsonify(_response_error_data("请求不存在", 404)), 404)


def make_response_405():
    return make_response(jsonify(_response_error_data("参数错误", 404)), 404)

def make_response_406(err_data,code):
    return make_response(jsonify(_response_error_data(err_data, code)), code)





def make_response_500():
    return make_response(jsonify(_response_error_data("无法连接到服务器", 500)), 500)


def make_response_1000():
    return make_response(jsonify(_response_error_data("操作失败", 1000)), 200)



def make_response_1001():
    return make_response(jsonify(_response_error_data("无文件", 1001)), 200)


def make_response_1002():
    return make_response(jsonify(_response_error_data("文件后缀不支持", 1002)), 200)


def make_response_1003():
    return make_response(jsonify(_response_error_data("正在升级中", 1003)), 200)


def make_response_1004():
    return make_response(jsonify(_response_error_data("网络连接失败，二维码生成失败", 1004)), 200)


def make_response_1005():
    return make_response(jsonify(_response_error_data("原密码错误，请验证", 1005)), 200)


def make_response_1006():
    return make_response(jsonify(_response_error_data("设备服务器连接失败，请联系管理员调试", 1006)), 200)

def make_response_1007():
    return make_response(jsonify(_response_error_data("相机启用失败，请联系管理员或重新尝试", 1007)), 200)




def make_response_1500():
    return make_response(jsonify(_response_error_data("该用户不可删除", 1500)), 200)


def make_response_error_1500():
    return make_response(jsonify(_response_error_data("该用户不可删除", 1500)), 200)


def make_response_1501():
    return make_response(jsonify(_response_error_data("该用户名不能添加", 1501)), 200)


def make_response_1502():
    return make_response(jsonify(_response_error_data("该用户名不能修改角色", 1502)), 200)


def make_response_1503():
    return make_response(jsonify(_response_error_data("名称超出长度限制", 1503)), 200)


def make_response_1504():
    return make_response(jsonify(_response_error_data("名称含有特殊字符，请修改", 1504)), 200)


def make_response_1505():
    return make_response(jsonify(_response_error_data("名称已存在，请修改", 1505)), 200)


def make_response_1511():
    return make_response(jsonify(_response_error_data("流协议已存在，请修改", 1511)), 200)


def make_response_1512():
    return make_response(jsonify(_response_error_data("活动最多可创建一百个", 1512)), 200)


def make_response_1506():
    return make_response(jsonify(_response_error_data("token失效", 1506)), 200)

def make_response_15068():
    return make_response(jsonify(_response_error_data("token未找到", 15068)), 200)


def make_response_1507():
    return make_response(jsonify(_response_error_data("缺少token", 1507)), 200)


def make_response_1508():
    return make_response(jsonify(_response_error_data("删除token失败", 1508)), 200)


def make_response_1509():
    return make_response(jsonify(_response_error_data("用户不存在", 1509)), 200)


def make_response_1510():
    return make_response(jsonify(_response_error_data("权限不足!", 1508)), 200)


def make_response_1530():
    return make_response(jsonify(_response_error_data("渠道码已生成，若需重新生成请先删除!", 1530)), 200)





def make_response_3000():
    return make_response(jsonify(_response_error_data("无资源", 3000)), 200)





def make_response_3001():
    return make_response(jsonify(_response_error_data("上传图片失败", 3001)), 200)


def make_response_3002():
    return make_response(jsonify(_response_error_data("上传视频失败", 3002)), 200)



def make_response_3101():
    return make_response(jsonify(_response_error_data("上传模板失败", 3101)), 200)


def make_response_3102():
    return make_response(jsonify(_response_error_data("添加关联景区失败", 3102)), 200)


def make_response_3103():
    return make_response(jsonify(_response_error_data("模板已关联其他景区，请勿修改", 3103)), 200)



def make_response_3202():
    return make_response(jsonify(_response_error_data("添加模板组失败", 3202)), 200)


 
def make_response_3301():
    return make_response(jsonify(_response_error_data("登陆失败,请检查账号密码", 3301)), 200)


def make_response_3302():
    return make_response(jsonify(_response_error_data("获取用户信息失败", 3302)), 200)



def make_response_3401():
    return make_response(jsonify(_response_error_data("无匹配模板", 3401)), 200)


def make_response_3402():
    return make_response(jsonify(_response_error_data("上传图片视频失败", 3402)), 200)
